import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import './assets/styles/global.css'
import { createPersistedState } from 'pinia-persistedstate-plugin'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { useThemeStore } from './stores/theme'
import { useLanguageStore } from './stores/language'
import i18nPlugin from './plugins/i18n'

const app = createApp(App)
const pinia = createPinia()
const persist = createPersistedState()
pinia.use(persist)
app.use(router)
app.use(pinia)
app.use(i18nPlugin);

const theme = useThemeStore()
theme.initTheme()

app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

const language = useLanguageStore()
language.init().then(()=>{
  app.mount('#app')
})